import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text("AnimatedContainer Shadow Demo")),
        body: const AnimatedShadowDemo(),
      ),
    );
  }
}

class AnimatedShadowDemo extends StatefulWidget {
  const AnimatedShadowDemo({super.key});

  @override
  _AnimatedShadowDemoState createState() => _AnimatedShadowDemoState();
}

class _AnimatedShadowDemoState extends State<AnimatedShadowDemo> {
  double _borderRadius = 10;
  double _elevation = 5;

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          AnimatedContainer(
            width: 100,
            height: 100,
            decoration: BoxDecoration(
              color: Colors.blue,
              borderRadius: BorderRadius.circular(_borderRadius),
              boxShadow: [
                BoxShadow(
                  color: Colors.black.withOpacity(0.2),
                  spreadRadius: 3,
                  blurRadius: _elevation,
                  offset: const Offset(0, 4),
                ),
              ],
            ),
            duration: const Duration(seconds: 1),
            curve: Curves.easeInOut,
          ),
          const SizedBox(height: 20),
          ElevatedButton(
            onPressed: () {
              setState(() {
                _borderRadius = _borderRadius == 10 ? 50 : 10;
                _elevation = _elevation == 5 ? 20 : 5;
              });
            },
            child: const Text('Animate Shadow & Border Radius'),
          ),
        ],
      ),
    );
  }
}
